package wangm.repository;

import wangm.bean.ExaminationPaper;
import wangm.util.DBOperatorComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

/**
 * 试卷repository (所有查询不写联合查询语句)
 *
 * @author zk
 * @date 2018-02-23 19:31
 */
@Repository
public class ExaminationPaperRepository {
    private static Logger logger = LoggerFactory.getLogger(ExaminationPaperRepository.class);
    /**
     * 当前表明，修改表名，必须同时修改该变量
     */
    public static final String thisTableName = "T_EXAMINATION_PAPER";
    /**
     * db operator
     */
    @Autowired
    private DBOperatorComponent dbOperatorComponent;

    /**
     *  根据id查询当前表
     *
     * @param id id
     * @return examinationBean
     */
    public ExaminationPaper getById(String id){
        try {
            return dbOperatorComponent.getById(id,thisTableName,ExaminationPaper.class);
        } catch (SQLException e) {
            logger.error("query " + thisTableName + "fail",e);
            return null;
        }
    }

}
